#ifndef	DARRAY_H
#define	DARRAY_H

#include	"typedef.h"

struct _DArray;
typedef struct _DArray DArray;

DArray *darray_create(size_t size, DataAllocFunc alloc_func, DataDestroyFunc destroy_func, void *ctxt);
void darray_destroy(DArray* thiz);
size_t darray_count(DArray *thiz);
size_t darray_alloc_size(DArray *thiz);

size_t darray_insert(DArray *thiz, size_t i, void *data);
void darray_remove(DArray *thiz, size_t i);

size_t darray_head(DList *thiz);
size_t darray_tail(DList *thiz);

void darray_for_each(DArray *thiz, size_t start, size_t end, 
		Direct direct, DataVisitFunc visit_func, void *ctxt);
size_t darray_find(DArray *thiz, size_t start, size_t end, 
		Direct direct, DataCmpFunc cmp_func, void *ctxt);

size_t darray_entry_next(DArray *thiz, size_t i);
void *darray_entry_value(DArray *thiz, size_t i);
void darray_entry_swap(DArray *thiz, size_t a, size_t b);
Ret darray_entry_valid(DArray *thiz, size_t entry);


#endif
